var app = getApp();
Component({
	options: {
		multipleSlots: true
	},
	data: {
		status: 0,
		navheight: 0,
		firstpage: false,
		ishome: false
	},
	properties:{
		title: {
			type: String,
			value: ''
		},
		soltmid:{
			type: Boolean,
			value: false
		},
		soltleft:{
			type: Boolean,
			value: false
		},
		back:{
			type: Boolean,
			value: false
		},
		backgroundColor:{
			type: String,
			value: ''
		},
		backnum:{
			type: Number,
			value: 1
		},
		titleLeft: {
			type: Boolean,
			value: false
		}
	},
	attached(){
		this.setNavheight();
		let pages = getCurrentPages();
		if (pages.length ==1) {
			this.setData({
				firstpage: true,
				ishome:(pages[0].is.indexOf('index/index') > -1 || pages[0].is.indexOf('myCenter/myCenter') > -1) ? true : false
			})
		}
	},
	methods:{
		setNavheight(){
			let sysinfo = app.globalData.window.all
			let statusHeight = sysinfo.statusBarHeight                
			let navheight = sysinfo.system.indexOf('iOS') > -1 ? 44 : 48;
			this.setData({
				status: statusHeight,
				navheight: navheight
			})
			this.triggerEvent('getNavHeight', { statusHeight, navheight })
		},
		goback(){
			if(this.data.back){
				this.triggerEvent('getback',{})
			}else{
				wx.navigateBack({
					delta: this.data.backnum
				})
			}
		}
	}
})
